var app = new Vue({
  el: "#app",
  data: {
    memberList: ["基础会员", "标准会员", "VIP会员", "旗舰会员", "尊享会员"], // 会员列表
    form: { follow: [] },
    rules: {
      follow: [
        { required: true, message: "请选择回访周期", trigger: "change" },
        { required: true, message: "请选择回访周期", trigger: "change" },
        { required: true, message: "请选择回访周期", trigger: "change" },
        { required: true, message: "请选择回访周期", trigger: "change" },
        { required: true, message: "请选择回访周期", trigger: "change" },
      ],
    },
  },
  mounted() {
    this.getConfig();
  },
  methods: {
    // 获取设置
    getConfig() {
      apiGetConfig()
        .then((res) => {
          const { data } = res;
          if (data) this.form.follow = data;
        })
        .catch((err) => {
          this.$message.error(err && err.msg);
        });
    },
    handleSubmit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.$confirm("是否确认修改内容", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning  ",
          }).then(() => {
            apiSetConfig({ data: this.form.follow })
              .then((res) => {
                this.$message.success("保存成功");
              })
              .catch((err) => {
                this.$message.error(err && err.msg);
              });
          });
        }
      });
    },
  },
});
